package com.gcd.gym.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gcd.gym.mapper.MemberMapper;
import com.gcd.gym.model.Member;
import com.gcd.gym.model.form.CourseOfMember;
import com.gcd.gym.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberServiceImpl implements MemberService {
    private MemberMapper memberMapper;

    @Autowired
    public void setMemberMapper(MemberMapper memberMapper) {
        this.memberMapper = memberMapper;
    }

    @Override
    public Page<Member> findMember(Page<Member> page, Member member) {
        return memberMapper.findMember(page, member);
    }

    @Override
    public int deleteMembersById(List<Integer> ids) {
        int count=0;
        for (Integer id:ids) {
            count+=memberMapper.deleteMembersById(id);
        }
        return count;
    }

    @Override
    public boolean addMember(Member member) {
        return memberMapper.insert(member)==1;
    }

    @Override
    public boolean editMember(Member member) {
        return memberMapper.updateById(member)==1;
    }

    @Override
    public List<CourseOfMember> searchMembersCourse(Integer memberId,Integer status) {
        return memberMapper.searchMembersCourse(memberId,status);
    }
}
